import { ajax } from '@/utils'

const baseUrl = '/monitor/cache'

export default {
  getCacheNames(): Promise<IGetCacheNamesRes> {
    return ajax.get(`${baseUrl}/getNames`)
  },
  getCacheKeys(...args: IGetCacheKeysReq): Promise<IGetCacheKeysRes> {
    return ajax.get(`${baseUrl}/getKeys/${args[0]}`)
  },
  clearCacheName(...args: IClearCacheNameReq): IVoidRes {
    return ajax.get(`${baseUrl}/clearName/${args[0]}`)
  },
  getCacheValue(...args: IGetCacheValueReq): Promise<IGetCacheValueRes> {
    return ajax.get(`${baseUrl}/value/${args[0]}`)
  },
  clearCacheKey(...args: IClearCacheKeyReq): IVoidRes {
    return ajax.delete(`${baseUrl}/clearKey/${args[0]}`)
  },
  getInfo(): Promise<IGetCacheInfoRes> {
    return ajax.get(`${baseUrl}/getInfo`)
  }
}
